﻿using FbHelperWP7NonUi.Settings;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace FbHelperNonUiTests
{    
    [TestClass()]
    public sealed class ProgramStateTest
    {
        [TestMethod()]
        public void CurrentStateTest()
        {
            ProgramState target = ProgramState.CurrentState;

            Assert.IsNotNull( target );
            Assert.IsNotNull( target.TextStyle );
            Assert.IsNotNull( target.History );
        }

        [TestMethod()]
        public void SaveTest()
        {
            ProgramState before = ProgramState.CurrentState;

            string pathName;

            if (before.History.RecentFile != null && before.History.RecentFile.Path != null)
                pathName = before.History.RecentFile.Path + '!';
            else
                pathName = "Test Path";

            before.History.RecentFile = new FileInfo()
            {
                Path = pathName
            };

            before.Save();

            ProgramState_Accessor.s_programState = null;

            ProgramState target = ProgramState.CurrentState;

            Assert.IsNotNull( target );
            Assert.IsNotNull( target.History );
            Assert.IsNotNull( target.History.RecentFile );
            Assert.IsNotNull( target.History.RecentFile.Path );
            Assert.AreEqual( pathName, target.History.RecentFile.Path );
        }
    }
}
